Home

Computer science

'

\ufeffWrite a program in C++ \ufeffor python to read from the user a single line (up to 255 \ufeffcharacters) \ufeffat a time and splits the line into lexemes, if possible. The program will determine whether each lexeme is a reserved word, an arithmetic operator, a special symbol, a number, or an identifier. The following arrays are already given:
\ufeff
char reservedWords[4][10]={ cin>>, for, int, while};
char operator[6][2]={ +, -, *, /, ++, --}
char special[7][3]={>, = , ; , ( , ) , >= ,,};
\ufeff
A number is an unsigned integer or a signed integer.
An identifier starts with a letter or _ \ufefffollowed by any number of letters, _, \ufeffand digits, and excludes any reserved word.
\ufeff
For each lexeme check whether it is a reserved word. If not, check whether it is a special symbol. If not, check whether it is a number. If not, check whether it is an identifier. If none of these, display invalid. \ufeffThe program must be case insensitive. Save it as Prog3 \ufeffand upload it on Canvas.

'

Answer